//
//  HKBaseViewController.m
//  KSBridgeDesign
//
//  Created by huzhaoke on 2021/5/3.
//

#import "HKBaseViewController.h"
#import "UIView+properties.h"
#import "HKNavigationBar.h"

@interface HKBaseViewController () <HKNavigationBarDelegate>

@end

@implementation HKBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = YES;
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.userDefinedNaviBar];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    [self.view bringSubviewToFront:self.userDefinedNaviBar];
    //开启右滑返回手势
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
           self.navigationController.interactivePopGestureRecognizer.delegate = nil;
   }
}

- (void)didTapBack {
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - properties

- (HKNavigationBar *)userDefinedNaviBar {
    if (!_userDefinedNaviBar) {
        _userDefinedNaviBar = [[HKNavigationBar alloc] initWithFrame:CGRectMake(0, 0, self.view.width, [HKNavigationBar naviBarHeight])];
        [_userDefinedNaviBar updateBackImageName:@"backImg"];
        _userDefinedNaviBar.delegate = self;
    }
    return _userDefinedNaviBar;
}

@end
